#include "level1.h"

Level1::Level1(QWidget *parent)
    : LevelScene(QPixmap(RESOURCE_DIR + "/Rose_Past_Map.png"),QImage(RESOURCE_DIR + "/Rose_Past_Mask.png"), parent)
{
    buildingImage = new GameBackground(QPixmap(RESOURCE_DIR + "/Rose_Past_Buildings.png"),mainScene);
    buildingImage->setZValue(1);

    // Add the tools
    quarantineTool = addTool(QString("Quarantien (Place road block)"),RESOURCE_DIR + "/buttons/Kit_Quarantine.png");
    sterilizationTool = addTool(QString("Sterilize building"),RESOURCE_DIR + "/buttons/Dean_Sterilize.png");

    // Add one story houses
    QPointF house1Info[22][2] = {{QPointF(776,476),QPointF(78,50)},
                                 {QPointF(841,476),QPointF(88,50)},
                                 {QPointF(776,541),QPointF(80,58)},
                                 {QPointF(841,541),QPointF(86,58)},
                                 {QPointF(926,621),QPointF(93,65)},
                                 {QPointF(990,621),QPointF(103,64)},
                                 {QPointF(926,686),QPointF(95,73)},
                                 {QPointF(990,686),QPointF(101,73)},
                                 {QPointF(1077,621),QPointF(108,65)},
                                 {QPointF(1141,621),QPointF(118,65)},
                                 {QPointF(1077,686),QPointF(110,73)},
                                 {QPointF(1141,686),QPointF(116,73)},
                                 {QPointF(926,771),QPointF(93,80)},
                                 {QPointF(990,771),QPointF(103,80)},
                                 {QPointF(926,836),QPointF(95,88)},
                                 {QPointF(990,836),QPointF(101,88)},
                                 {QPointF(841,621),QPointF(88,65)},
                                 {QPointF(841,686),QPointF(86,73)},
                                 {QPointF(926,1136),QPointF(95,118)},
                                 {QPointF(990,1136),QPointF(101,118)},
                                 {QPointF(1077,1136),QPointF(110,118)},
                                 {QPointF(1141,1136),QPointF(116,118)}
                                 };

    for (unsigned int index = 0; index < (sizeof(house1Info)/(sizeof(*house1Info[0])*2)); index++)
    {
        char buildingColor = '1' + (rand() % 4);
        addBuilding(QPoint(house1Info[index][1].toPoint()),QPointF(house1Info[index][0]),QPixmap(RESOURCE_DIR + "/buildings/Rose_1home" + buildingColor + ".png"));
    }

    // Add two story houses
    QPointF house2Info[4][2] = {{QPointF(1076,522),QPointF(110,59)},
                                {QPointF(1141,522),QPointF(116,59)},
                                {QPointF(1226,822),QPointF(125,89)},
                                {QPointF(1291,822),QPointF(131,89)}
                                };

    for (unsigned int index = 0; index < (sizeof(house2Info)/(sizeof(*house2Info[0])*2)); index++)
    {
        char buildingColor = '1' + (rand() % 4);
        addBuilding(QPoint(house2Info[index][1].toPoint()),QPointF(house2Info[index][0]),QPixmap(RESOURCE_DIR + "/buildings/Rose_2home" + buildingColor + ".png"));
    }

    // Add three story houses
    QPointF house3Info[3][2] = {{QPointF(1222,472),QPointF(131,57)},
                                {QPointF(1222,922),QPointF(131,102)},
                                {QPointF(1222,1072),QPointF(131,117)}
                                };

    for (unsigned int index = 0; index < (sizeof(house3Info)/(sizeof(*house3Info[0])*2)); index++)
    {
        char buildingColor = '1' + (rand() % 4);
        addBuilding(QPoint(house3Info[index][1].toPoint()),QPointF(house3Info[index][0]),QPixmap(RESOURCE_DIR + "/buildings/Rose_3home" + buildingColor + ".png"));
    }

    // Add other buildings
    addBuilding(QPoint(88,87),QPointF(841,800),QPixmap(RESOURCE_DIR + "/buildings/1PostOffice.png"));
    addBuilding(QPoint(93,103),QPointF(920,935),QPixmap(RESOURCE_DIR + "/buildings/1FireStation.png"));

    QString convertString;

    for (int count = 0; count<100; count ++)
    {
        convertString.setNum((rand()%12) + 1);
        addPerson(QPixmap(RESOURCE_DIR + "/people/Dean_Person" + convertString + ".png"),buildings.at(rand() % buildings.length()));
    }

    addPerson(QPixmap(RESOURCE_DIR + "/Kit_Person.png"),buildings.at(2));
    people.last()->virus = new Virus(0,10,0,0,0,0);

}
